const util = require('../../utils/util.js');
const mobile = require('../../config.js').mobile;
const app = getApp();
const inidata = '你好\n   周四    来啦  我们什么时候聚聚&lt;'
const extraLine = [];
Page({
  data: {
    // 图标
    iconD:[{
      size:20,
      color:"red",
      type:"success"
    }, {
      size: 30,
      color: "orange",
      type: "success_no_circle"
      }, {
        size: 40,
        color: "yellow",
        type: "info"
    }, {
      size: 50,
      color: "green",
      type: "warn"
      }, {
        size: 60,
        color: "blue",
        type: "waiting"
    }],
    text: inidata,
    html: '<div class="div_class" style="line-height: 20px; color: red;"> html输出</div>',
    nodes: [{
      name: 'div',
      attrs: {
        class: 'div_class',
        style: 'line-height: 20px; color: red;'
      },
      children: [{
        type: 'text',
        text: 'nodes输出'
      }]
    }],
    // 进度条的配置
    jdt:{
      num:20,
      show:true,
      color:"pink",
      active:true,
      width:22
    },
    // 媒体》audio
    mt:{
      poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
      name: '此时此刻',
      author: '许巍',
      src: 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46',
      audioAction:{ 
         method: 'play' 
      }
    },
    //媒体》img
    pic:{
      style:{
        width:"150px",
        height:'50px'
      },
      src:"../../image/wifi.png",
      mode: "left", //图片裁剪、缩放的模式 bottom right
    },
    // 媒体》视频
    // https://developers.weixin.qq.com/miniprogram/dev/component/video.html
    sp:{
      src:"http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400",
      autoplay:false,//自动播放
      loop: false,//是否循环播放
      danmuList: [{//弹幕列表
        text: '第 1s 出现的弹幕',
        color: '#ff0000',
        time: 1
      },
      {
        text: '第 3s 出现的弹幕',
        color: '#ff00ff',
        time: 3
      }]
    },
    srcCamera:"",
    videoSrc:"",
  },
  onLoad: function () {
    this.ctxCamera = wx.createCameraContext();
    this.getdata()
  },
  getdata:function(){
    var options = {
      header: { 'content-type': 'application/x-www-form-urlencoded'},
      url: mobile, 
      data: {
       tel : 18695600382
      },
      success: function (res) { 
        console.log(res.data) 
      },
      fail: function (err) {
        console.log(err)
      },
      complete: function () { 
        util.hideLoading() 
      }
    } 
    util.XHR(options) 
  },
  onReady: function (res) {
    this.videoContext = wx.createVideoContext('myVideo')
  },
  add: function(e){
    extraLine.push("新的一行\n在一行")
    this.setData({
      text: inidata + '\n' + extraLine.join('\n')
    })
  }, 
  // 音频 播放触发事件
  audioPlayed: function (e) {
    console.log('audio is playing')
  },
  // 音频 播放
  playMt:function(){
    this.setData({
      audioAction:{
        method:'play'
      }
    })
  }, 
  //音频 暂停
  pauseMt: function () {
    this.setData({
      audioAction: {
        method: 'pause'
      }
    })
  },
  // 视频出错
  videoErrorCallback: function (e) {
    console.log('视频错误信息:')
    console.log(e.detail.errMsg)
  },
  // 照相
  takePhoto() { 
    this.ctxCamera.takePhoto({
      quality: 'high',
      success: (res) => {
        this.setData({
          srcCamera: res.tempImagePath
        })
      }
    })
  },
  // 照相机出错
  errorCamera(e){
    console.log(e.detail)
  },
  // 录像 - 开始
  startRecord() {
    this.ctxCamera.startRecord({
      success: (res) => {
        console.log('startRecord')
      }
    })
  },
  // 录像 - 结束
  stopRecord() {
    this.ctxCamera.stopRecord({
      success: (res) => {
        this.setData({
          srcCamera: res.tempThumbPath,
          videoSrc: res.tempVideoPath
        })
      }
    })
  },
})
